# Scrapy settings for baidutieba project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://docs.scrapy.org/en/latest/topics/settings.html
#     https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://docs.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'baidutieba'

SPIDER_MODULES = ['baidutieba.spiders']
NEWSPIDER_MODULE = 'baidutieba.spiders'

# LOG_LEVEL = "WARNING"
# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62'

# Obey robots.txt rules
ROBOTSTXT_OBEY = False

# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
#CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
  'Accept': 'application/json, text/javascript, */*; q=0.01',#'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language': 'zh-CN,zh;q=0.9',
    'Accept-Encoding':'gzip, deflate, br',
    'sec-ch-ua':'".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
    'sec-ch-ua-platform': '"Windows"',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
    'Referer': 'https://tieba.baidu.com/',
    #'Cookie': 'BIDUPSID=5F2F6BBA4F387950C2CDA0A4CFB0AD38; PSTM=1647676420; BAIDUID=5F2F6BBA4F38795045674E48A539B8F3:FG=1; BAIDUID_BFESS=95475C52D116E9AE5416ABB34932191F:FG=1; ZFY=ktq5iEJO0:BEo8kZYgTpAyAbWKDI9:B9IfFX9t:AvRjNqU:C; H_PS_PSSID=36826_36544_36463_36726_36413_36955_36949_36166_36918_36569_36807_36779_36789_36745_26350; BA_HECTOR=8g0g850g2g24agalag2785mb1heagrq16; Hm_lvt_98b9d8c2fd6608d564bf2ac2ae642948=1659192331; Hm_lpvt_98b9d8c2fd6608d564bf2ac2ae642948=1659192331; ab_sr=1.0.1_OTEyMzJkMjdkN2FkNGI4N2RiMTE5NjA5YjNlMmZiMjYwNjlkNDNhZjUxYjMzYjhhMGRhZDQxZWRjODhiMDZlZDQzZDkzZjhiNGI3NTBmOGMzMDFlZTFiNzRmMTkzOTlhZWMyN2YwNDM2ZTQxMWQ3MGZhYmMyODNiMzYyNTk3YzEzNjBhNDQ2ZjE2ZTNiMWQyNjVkOTljYWNlNjExZDI3Ng==; st_data=4b63108efda9126d7756f225d42463519bf9ceae8e43dce6f778eae7a5ab1fd28b41e672b624ad8c176cfc2729290f6dae78d4eebf19bd3ddeea2888859a45af4a0f1ff6745baca06fbd5675aa458fb23638d0caf6aedd637f623ee4a2e8becd; st_key_id=17; st_sign=090b2777; BAIDU_WISE_UID=wapp_1659192342075_48; USER_JUMP=-1; RT="z=1&dm=baidu.com&si=83sq7r337wp&ss=l6809vp7&sl=2&tt=13r&bcn=https://fclog.baidu.com/log/weirwood?type=perf&ld=1w2&ul=sx3v&hd=sy27"',
}

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
#    'baidutieba.middlewares.BaidutiebaSpiderMiddleware': 543,
#}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
   # 'baidutieba.middlewares.BaidutiebaDownloaderMiddleware': 543,
    'baidutieba.middlewares.SeleniumMiddleware': 543,

}

SELENIUM_TIMEOUT = 10

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
#}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
   'baidutieba.pipelines.BaidutiebaPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
# HTTPCACHE_ENABLED = True
# HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
